//
//  IFontType.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/15.
//

import Foundation
//字体
enum IFontType : String, CaseIterable, Identifiable {
    var id: String {
        self.rawValue
    }
    case number = "ChillRoundGothic_Bold"// 数字字体
    case custom = "HappyZcool-2016"// 站酷快乐字体
}



// 打印自定义字体名称和文件名
func printCustomFonts() {
    let customFonts = getCustomFontsWithFileNames()
    if customFonts.isEmpty {
        showLog("字体","没有发现字体")
    } else {
        showLog("字体","Custom Fonts:")
        for (fileName, fontName) in customFonts {
            showLog("字体","  File: \(fileName) -> Font Name: \(fontName)")
        }
    }
}

// 获取自定义字体名称和文件名
func getCustomFontsWithFileNames() -> [(String, String)] {
    let customFonts = Bundle.main.urls(forResourcesWithExtension: "ttf", subdirectory: nil) ?? []
    var fontInfo: [(String, String)] = []
    
    for fontURL in customFonts {
        if let fontDataProvider = CGDataProvider(url: fontURL as CFURL),
           let font = CGFont(fontDataProvider) {
            if let fontName = font.postScriptName as String? {
                // 获取文件名（不包含路径）
                let fileName = fontURL.lastPathComponent
                fontInfo.append((fileName, fontName))
            }
        }
    }
    
    return fontInfo
}
